package com.platform.controller.platform;

import com.platform.common.annotation.Log;
import com.platform.common.core.domain.AjaxResult;
import com.platform.common.core.page.TableDataInfo;
import com.platform.common.enums.BusinessType;
import com.platform.common.enums.ResultEnum;
import com.platform.common.exception.BusinessException;
import com.platform.system.domain.dto.device.AiUiConfigDto;
import com.platform.system.domain.vo.device.AiUiConfigVo;
import com.platform.system.service.ISysAiUiConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Huangkai
 */
@Slf4j
@RestController
@RequestMapping("/aiui/config")
public class AiUiConfigController {

    @Resource
    ISysAiUiConfigService sysAiUiConfigService;

    /**
     * 通过类型查询芯片详情
     */
    @Log(title = "查询aiui配置列表", businessType = BusinessType.OTHER)
    @GetMapping("/selectAiUiConfigList")
    public TableDataInfo selectAiUiConfigList(@Validated AiUiConfigVo aiUiConfigVo) {
        return sysAiUiConfigService.selectAiUiConfigList(aiUiConfigVo);
    }
    /**
     * 查询详情
     */
    @Log(title = "查询详情", businessType = BusinessType.OTHER)
    @GetMapping("/selectAiUiConfig/{uid}")
    public AjaxResult selectAiUiConfig(@PathVariable(value = "uid") String uid) {
        AiUiConfigDto aiUiConfigDto = sysAiUiConfigService.selectAiUiConfig(uid);
        if(aiUiConfigDto == null){
            throw new BusinessException(ResultEnum.DATA_NOT_EXIST);
        }
        return AjaxResult.success(aiUiConfigDto);
    }

    /**
     * 新增
     */
    @Log(title = "新增aiui配置", businessType = BusinessType.INSERT)
    @PostMapping("/insertAiUiConfig")
    public AjaxResult insertAiUiConfig(@RequestBody @Validated AiUiConfigVo aiUiConfigVo) {
        return sysAiUiConfigService.insertAiUiConfig(aiUiConfigVo);
    }

    /**
     * 修改状态
     */
    @Log(title = "修改状态", businessType = BusinessType.UPDATE)
    @PostMapping("/updateAiUiConfigStatus")
    public AjaxResult updateAiUiConfigStatus(@RequestBody @Validated AiUiConfigVo aiUiConfigVo) {
        return sysAiUiConfigService.updateAiUiConfigStatus(aiUiConfigVo);
    }



    /**
     * 删除
     */
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @PostMapping("/deleteAiUiConfigList")
    public AjaxResult deleteAiUiConfigList(@RequestBody @Validated AiUiConfigVo aiUiConfigVo) {
        return sysAiUiConfigService.deleteAiUiConfigList(aiUiConfigVo);
    }

    /**
     * 修改
     */
    @Log(title = "修改状态", businessType = BusinessType.UPDATE)
    @PostMapping("/updateAiUiConfig")
    public AjaxResult updateAiUiConfig(@RequestBody @Validated AiUiConfigVo aiUiConfigVo) {
        return sysAiUiConfigService.updateAiUiConfig(aiUiConfigVo);
    }

}
